#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N = 1e6 + 10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
int n, q, x, k, a[N];
void solve()
{
	cin >> n >> q;
	priority_queue<int, vector<int>, less<int>> pq;
	for (int i = 0; i < n; i++)
	{
		cin >> x;
		pq.push(x);
	}
	// while(!pq.empty())
	// {
	// 	cout<<pq.top()<<" ";
	// 	pq.pop();
	// }

	for (int i = 1; i <= N; i++)
	{
		int tp = pq.top();
		if (tp == 1) break;
		pq.pop();
		tp = __builtin_popcount(tp);
		pq.push(tp);
		tp=pq.top();
		a[i]=tp;
	}


	while (q--)
	{
		cin >> k;
		if (k > N || a[k] == 0)
		{
			cout << 1 << '\n';
		}
		else
		{
			cout << a[k] << '\n';
		}
	}


}

int main()
{
	close();
	solve();
	return 0;
}